﻿require.config({
  urlArgs: "version=20170501",
  paths: {
    'jquery': '../packages/jquery-2.14-min',
    'bootstrap': '../../bootstrap/js/bootstrap.min',
  },
  shim: {
    'bootstrap': {
      deps: ['jquery'],
      exports: 'bootstrap'
    }
  }
});




require(['jquery','bootstrap'], function ($) {

	var myChart = echarts.init(document.getElementById('content-right-classify1'));
  $('#graph-6001').click(function () {
  	drawGraph_6001();
	  $('#graph-show').modal('show');
  });
  $('#graph-6002').click(function () {
  	drawGraph_6002();
	  $('#graph-show').modal('show');
  });
  function drawGraph_6001() {
		/**
		 *ajax获取相应的数据 专利技术申请趋势
		 */
		dataX = [];
	  	valueY1 = [];
	  	valueY2 = [];
	  	valueY3 = [];
	    valueY4 = [];
	  	valueY5 = [];
	  	valueY6 = [];
	  	valueY7 = [];
	    valueY8 = [];
	  	valueY9 = [];
	  	valueY10 = [];
	  	valueYCname = [];
		$.ajax({
		type : 'GET',
		url : '/draw/graph/6001',
		//data : jsonda,
		cache: false,
		async:false,
		//contentType: "application/json; charset=utf-8",
		dataType : 'json',
		success : function(res) {
			valueY1 = res.graph_6001_y_company1;
	  		valueY2 = res.graph_6001_y_company2;
	  		valueY3 = res.graph_6001_y_company3;
	   		valueY4 = res.graph_6001_y_company4;
	  		valueY5 = res.graph_6001_y_company5;
	  		valueY6 = res.graph_6001_y_company6;
	  		valueY7 = res.graph_6001_y_company7;
	  	 	valueY8 = res.graph_6001_y_company8;
	  		valueY9 = res.graph_6001_y_company9;
	  		valueY10 = res.graph_6001_y_company10;
	  		valueYCname = res.graph_6001_y_companyname;       
			dataX = res.xAxis;
		},
		error : function(xml, err, throwInfo) {
			alert(err);
		}
		});
		myChart.clear();

		

	option = {
	title: {
	    text: '专利技术申请趋势'
	},
	tooltip: {
	    trigger: 'axis'
	},
	legend: {
	    data:valueYCname,
	    top:'5%',
	    left:'10%',
	    //orient: 'vertical'
	},
	grid: {
	    left: '3%',
	    right: '4%',
	    bottom: '3%',
	    containLabel: true
	},
	toolbox: {
	    feature: {
	        saveAsImage: {}
	    }
	},
	xAxis: {
	    type: 'category',
	    //boundaryGap: false,
	    data: dataX,
	    name:'申请年',
	   	nameLocation:'middle',
	  	nameGap: 20
	},
	yAxis: {
	    type: 'value',
	    name:'专利申请量(项)',
	   	nameLocation:'middle',
	  	nameGap: 30
	},
	series: [
	    {
	        name:valueYCname[0],
	        type:'line',
	        stack:'cz',
	        data:valueY1
	    },
	    {
	        name:valueYCname[1],
	        type:'line',
	        stack:'cz',
	        data:valueY2
	    },
	    {
	        name:valueYCname[2],
	        type:'line',
	        stack:'cz',
	        data:valueY3
	    },
	    {
	        name:valueYCname[3],
	        type:'line',
	        stack:'cz',
	        data:valueY4
	    },
	    {
	        name:valueYCname[4],
	        type:'line',
	        stack:'cz',
	        data:valueY5
	    },
	    {
	        name:valueYCname[5],
	        type:'line',
	        stack:'cz',
	        data:valueY6
	    },
	    {
	        name:valueYCname[6],
	        type:'line',
	        stack:'cz',
	        data:valueY7
	    },
	    {
	        name:valueYCname[7],
	        type:'line',
	        stack:'cz',
	        data:valueY8
	    },
	    {
	        name:valueYCname[8],
	        type:'line',
	        stack:'cz',
	        data:valueY9
	    },
	    {
	        name:valueYCname[9],
	        type:'line',
	        stack:'cz',
	        data:valueY10
	    }
	]

	};

	myChart.setOption(option);
		 
	}

function drawGraph_6002() {
	myChart.clear();
	var xAxisData = [];
	var data1 = [];
	var data2 = [];
	for (var i = 0; i < 100; i++) {
	    xAxisData.push('类目' + i);
	    data1.push((Math.sin(i / 5) * (i / 5 -10) + i / 6) * 5);
	    data2.push((Math.cos(i / 5) * (i / 5 -10) + i / 6) * 5);
	}
		option = {
			    title: {
			        text: '柱状图动画延迟'
			    },
			    legend: {
			        data: ['bar', 'bar2'],
			        align: 'left'
			    },
			    toolbox: {
			        // y: 'bottom',
			        feature: {
			            magicType: {
			                type: ['stack', 'tiled']
			            },
			            dataView: {},
			            saveAsImage: {
			                pixelRatio: 2
			            }
			        }
			    },
			    tooltip: {},
			    xAxis: {
			        data: xAxisData,
			        silent: false,
			        splitLine: {
			            show: false
			        }
			    },
			    yAxis: {
			    },
			    series: [{
			        name: 'bar',
			        type: 'bar',
			        data: data1,
			        animationDelay: function (idx) {
			            return idx * 10;
			        }
			    }, {
			        name: 'bar2',
			        type: 'bar',
			        data: data2,
			        animationDelay: function (idx) {
			            return idx * 10 + 100;
			        }
			    }],
			    animationEasing: 'elasticOut',
			    animationDelayUpdate: function (idx) {
			        return idx * 5;
			    }
			};
		 myChart.setOption(option);
	}
});